<div class="panel panel-default">
	<div class="panel-heading">Registro de Vendas - Produtos</div>
	<div class="panel-body">
		<form name="prodForm" class="form-inline" novalidate>
			<div class="form-group" ng-class="{ 'has-error' : prodForm.referencia.$invalid && !prodForm.referencia.$pristine }">
				<label for="produtoTmp">Produto</label>
				<angucomplete style="display:inline" id="produtoTmp" placeholder="Pesquisar produto" pause="400" selectedobject="produtoTmp" url="{{produtosUrl}}" titlefield="referencia,descricao" minlength="3" inputclass="form-control input-sm" matchclass="highlight" />
			</div>
			<div class="form-group" ng-class="{ 'has-error' : prodForm.quantidade.$invalid && !prodForm.quantidade.$pristine }">
				<label for="quantidade">Quantidade</label>
				<input type="text" class="form-control input-sm" id="quantidade" name="quantidade" maxlength="6" placeholder="Qtde." ng-model="quantidade" required ng-focus="setaPreco()"/>
			</div>
			<div class="form-group" ng-class="{ 'has-error' : prodForm.preco.$invalid && !prodForm.preco.$pristine }">
				<label for="preco">Pre&ccedil;o (R$)</label>
				<input type="text" class="form-control input-sm moeda" id="preco" name="preco" maxlength="10" placeholder="Pre&ccedil;o (R$)" ng-model="preco" simon-decimal-format readonly="readonly" ng-focus="setaPreco()"/>
			</div>
			<div class="form-group" ng-class="{ 'has-error' : prodForm.desconto.$invalid && !prodForm.desconto.$pristine }">
				<label for="desconto">Desconto (%)</label>
				<input type="text" class="form-control input-sm" id="desconto" name="desconto" maxlength="2" ng-model="desconto" required ng-focus="setaPreco()"/>
			</div>
			<button class="btn btn-primary" id="btnAdicionar" ng-click="addProd()" role="button" ng-disabled="prodForm.$invalid" ng-focus="setaPreco()">Adicionar</button>
		</form>
	</div>
	<table class="table table-striped table-bordered" ng-if="venda.itemVendas.length > 0">
		<thead>
			<tr>
				<th>Refer&ecirc;ncia</th>
				<th>Quantidade</th>
				<th>Pre&ccedil;o Venda</th>
				<th>Pre&ccedil;o Praticado</th>
				<th>Desconto</th>
				<th width="60px">Excluir</th>
			</tr>
		</thead>
		<tbody>
			<tr ng-repeat="item in venda.itemVendas">
				<td>{{item.produto.referencia}}</td>
				<td>{{item.quantidade}}</td>
				<td>{{item.precoVenda|currency}}</td>
				<td>{{item.precoPraticado|currency}}</td>
				<td>{{item.desconto}}</td>
				<td class="center">
					<button class='glyphicon glyphicon-remove' ng-click="delProd(item, $index)" role='button'></button>
				</td>
			</tr>
		</tbody>
	</table>
</div>
<div class="panel panel-default">
	<div class="panel-heading">Registro de Vendas - Pagamento</div>
	<div class="panel-body">
		<form name="vendaForm" novalidate>
			<div class='row'>
				<div class='col-sm-4'>
					<div class="form-group" ng-class="{ 'has-error' : vendaForm.selFormPagto.$invalid && !vendaForm.selFormPagto.$pristine }">
						<label for="selFormPagto">Forma de Pagamento</label>
						<select class="form-control input-sm" id="selFormPagto" name="selFormPagto" ng-model="venda.formaPagamento.id" ng-options="f.id as f.descricao for f in formsPagto" required>
					    	<option value="">Selecione</option>
					  	</select>
					</div>
				</div>
				<div class='col-sm-4'>
					<div class="form-group" ng-class="{ 'has-error' : vendaForm.selParcelas.$invalid && !vendaForm.selParcelas.$pristine }">
						<label for="selParcelas">Qtd. de Parcelas</label>
						<select class="form-control input-sm" id="selParcelas" name="selParcelas" ng-model="venda.parcelas" required>
							<option value="1" selected>Uma vez</option>
						    <option value="2">Duas vezes</option>
						    <option value="3">Tr&ecirc;s vezes</option>
						    <option value="4">Quatro vezes</option>
						</select>
					</div>
				</div>
				<div class='col-sm-4'>
					<div class="form-group">
						<label for="valorTotal">Valor Total (R$)</label>
						<input type="text" class="form-control input-sm" id="valorTotal" name="valorTotal" ng-model="venda.valorTotal" simon-decimal-format readonly="readonly"/>
					</div>
				</div>
			</div>
			<div class='row'>
				<div class='col-sm-4'>
					<div class="form-group" ng-class="{ 'has-error' : vendaForm.notaFiscal.$invalid && !vendaForm.notaFiscal.$pristine }">
						<label for="notaFiscal">Nota Fiscal</label>
						<input type="text" class="form-control input-sm" id="notaFiscal" name="notaFiscal" maxlength="20" ng-model="venda.notaFiscal" required/>
					</div>
				</div>
				<div class='col-sm-4'>
					<div class="form-group" ng-class="{ 'has-error' : vendaForm.selFunc.$invalid && !vendaForm.selFunc.$pristine }">
						<label for="selFunc">Vendedor</label>
						<select class="form-control input-sm" id="selFunc" name="selFunc" ng-model="venda.funcionario.id" ng-options="f.id as f.nomeCompleto for f in funcionarios" required>
					    	<option value="">Selecione</option>
					  	</select>
					</div>
				</div>
				<div class='col-sm-4'>
					<div class="form-group" ng-class="{ 'has-error' : vendaForm.cliente.$invalid && !vendaForm.cliente.$pristine }">
						<label for="cliente">Cliente</label>
					  	<angucomplete id="cliente" placeholder="Pesquisar clientes" pause="400" selectedobject="clienteTmp" url="{{clientesUrl}}" titlefield="nome,sobrenome" minlength="3" inputclass="form-control input-sm" matchclass="highlight"/>
					</div>
				</div>
			</div>
			<button class="btn btn-primary" id="btnFinalizar" ng-click="addVenda()" role="button" ng-disabled="vendaForm.$invalid">Finalizar Venda</button>
		</form>
	</div>
</div>